home *** CD-ROM | disk | FTP | other *** search
/ Young Minds / Young Minds Interactive CD-ROM.ISO / sdi / rocks.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-06-18  |  1.6 KB  |  87 lines

  1. /******************************  laser.c *******************************/
  2. #include <pixrect/pixrect_hs.h>
  3. #include <sunwindow/notify.h>
  4. #include "sdi.h"
  5.  
  6. /*
  7.  * Copyright 1987 by Mark Weiser.
  8.  * Permission to reproduce and use in any manner whatsoever on Suns is granted
  9.  * so long as this copyright and other identifying marks of authorship
  10.  * in the code and the game remain intact and visible.  Use of this code
  11.  * in other products is reserved to me--I'm working on Mac and IBM versions.
  12.  */
  13.  
  14. /*
  15.  * All rock-specific code is here.
  16.  */
  17.  
  18. struct rock {
  19.     int x1, y1, x2, y2, number;
  20.     struct circ *type;
  21.     struct rock *next;
  22.     Pixwin *pw;
  23. } *rock_head = NULL;
  24.  
  25.  
  26.  
  27. /*
  28.  * Throw some rocks out.
  29.  */
  30. start_rocks(pw, x1, y1, x2, y2, number, type)
  31. Pixwin *pw;
  32. struct circ *type;
  33. {
  34.     struct rock real_r, *r = &real_r;
  35.     r->x1 = x1; r->x2 = x2; r->y1 = y1; r->y2 = y2;
  36.     r->number = number; r->type = type; r->pw = pw;
  37.     draw_rock(r);
  38. }
  39.  
  40. draw_rock(r)
  41. register struct rock *r;
  42. {
  43.     double x, y, xinc, yinc, fabs();
  44.     int i;
  45.     x = r->x1;
  46.     y = r->y1;
  47.     xinc = (double)(r->x2-r->x1)/(double)r->number;
  48.     yinc = (double)(r->y2-r->y1)/(double)r->number;
  49.     for (i=0; i < r->number; i += 1) {
  50.         start_blast((int)x, (int)y, 0, 4, r->pw, r->type);
  51.         x += xinc;
  52.         y += yinc;
  53.     }
  54. }
  55.  
  56. /*
  57.  * Add_rock, doto_rocks, and delete_rock are unused at this time, but
  58.  * they were once used, and worked.
  59.  */
  60.  
  61. add_rock(r)
  62. struct rock *r;
  63. {
  64.     r->next = rock_head;
  65.     rock_head = r;
  66. }
  67.  
  68. doto_rocks()
  69. {
  70. }
  71.  
  72. delete_rock(r)
  73. struct rock *r;
  74. {
  75.     struct rock *tr = rock_head;
  76.     if (r == tr) {
  77.         rock_head = r->next;
  78.         return;
  79.     }
  80.     while (tr != NULL && tr->next != r) {
  81.         tr = tr->next;
  82.     }
  83.     if (tr != NULL) {
  84.         tr->next = r->next;
  85.     }
  86. }
  87.